package com.axiu;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;

public class ImageActivity extends AppCompatActivity {

    private int[] images = new int[]{
            R.drawable.push1,
            R.drawable.push2,
            R.drawable.push3
    };

    private int current = 0;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_image);
        RelativeLayout layout = (RelativeLayout) findViewById(R.id.root);
        final ImageView image = new ImageView(this);
        layout.addView(image);
        image.setImageResource(images[0]);
        image.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                current++;
                image.setImageResource(images[current]);
                if(current == 2){
                    current = -1;
                }
            }
        });
    }
}
